package 常用类.Math类;

import java.util.Random;

public class Math {
    public static void main(String[] args) {
        //ceil向上取整
        double d= java.lang.Math.ceil(4.3);
        System.out.println("d = " + d);
        //floor向下取整
        double d1= java.lang.Math.floor(3.7);
        System.out.println("d1 = " + d1);
        //pow平方(求幂)
        double d3= java.lang.Math.pow(5,3);
        System.out.println("d3 = " + d3);
        //sqrt开方
        double d4= java.lang.Math.sqrt(9);
        System.out.println("d4 = " + d4);
        //abs绝对值
        int d5= java.lang.Math.abs(-9);
        System.out.println("d5 = " + d5);
        //round四舍五入
        double d6= java.lang.Math.round(4.5);
        System.out.println("d6 = " + d6);
        //max,min最大值和最小值
        int d7= java.lang.Math.max(5,7);
        System.out.println("d7 = " + d7);
        int d8= java.lang.Math.min(5,7);
        System.out.println("d8 = " + d8);
        //random随机数
        //获取随机数的方法一
        Random s1 = new Random();
        int i=s1.nextInt(5);//0--4
        System.out.println("i = " + i);
        double v=s1.nextDouble();
        System.out.println("v = " + v);
        //获取随机数的方法二
        double a = java.lang.Math.random();
        System.out.println("a = " + (int)(a*10));//0--10
    }
}
